//
//  PYLabelController.m
//  RNCommunity
//
//  Created by 朱吉峥 on 2020/2/28.
//  Copyright © 2020 朱吉峥. All rights reserved.
//

#import "PYLabelController.h"
#import "RNTYYLabel.h"

@interface PYLabelController ()

@end

@implementation PYLabelController

- (void)viewDidLoad {
    [super viewDidLoad];
    RNTYYLabel *contentL = [[RNTYYLabel alloc] init];
    //设置多行
    contentL.numberOfLines = 0;
    //这个属性必须设置，多行才有效
    contentL.preferredMaxLayoutWidth = kScreenWidth - 20;
    contentL.gifFontSize = 20;
    contentL.contentFontSize = 15;
    contentL.frameStr = NSStringFromCGRect(CGRectMake(10, 5, kScreenWidth - 20, 0));
    contentL.content = @"封印混沌，以护苍[舞蹈][舞蹈][拍手][舞蹈][舞蹈][拍手生，《神武4》电脑版首篇门派小说《大道无名》今日正式上线，同名广播剧同步开启播放，深度揭秘轩辕黄帝三十...";
    CGSize maxSize = CGSizeMake(contentL.preferredMaxLayoutWidth, MAXFLOAT);
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        //计算文本尺寸
        YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:maxSize text:contentL.attributedText];
        //    contentL.textLayout = layout;
//        contentL.lineBreakMode = NSLineBreakByCharWrapping;
        CGFloat introHeight = layout.textBoundingSize.height;
        contentL.height = introHeight;
        [self.view addSubview:contentL];
        NSLog(@"introHeight = %f", introHeight);
    });
    
}


@end
